#include <queue>

using namespace std;

class RecentCounter {
public:
    RecentCounter() {}

    int ping(int t) {
        q.push(t);
        while (q.front() < t - 3000) {
            q.pop();
        }

        return q.size();
    }

private:
    queue<int> q;
};

int main() {
    // Test case 1
    RecentCounter counter1;
    int result1 = counter1.ping(1);  // 返回 1，[1, 1]
    result1 = counter1.ping(100);    // 返回 2，[1, 100]
    result1 = counter1.ping(3001);   // 返回 3，[1, 100, 3001]
    result1 = counter1.ping(3002);   // 返回 3，[100, 3001, 3002]

    // Test case 2
    RecentCounter counter2;
    int result2 = counter2.ping(2000);  // 返回 1，[2000, 2000]
    result2 = counter2.ping(3000);      // 返回 2，[2000, 3000]
    result2 = counter2.ping(4000);      // 返回 3，[2000, 3000, 4000]
    result2 = counter2.ping(4001);      // 返回 3，[3000, 4000, 4001]

    return 0;
}